<%@page import="java.util.ArrayList"%>
<%@page import="es.cea.Tarea"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Collection"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%
    try
    {
    Class.forName("com.mysql.jdbc.Driver");
    Connection conexion = DriverManager.getConnection (
    					"jdbc:mysql://localhost/holamundo",
   						"root", 
    					"root");
    Statement s = conexion.createStatement();
    ResultSet rs = s.executeQuery ("select * from tareas");
    List<Tarea> tareas=new ArrayList<Tarea>();
    while(rs.next()){
    	Tarea t=new Tarea(0, rs.getString("nombre"), rs.getString("descripcion"));
    	tareas.add(t);
    }
	request.setAttribute("tareas", tareas);
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table border="1">
<tr>
<td>NOMBRE</td>
<td>DESCRIPCION</td>
<td></td>
</tr>
<c:forEach items="${requestScope.tareas}" var="tarea">
<tr>
	<td>${tarea.titulo}</td>
	<td> ${tarea.descripcion}</td>
	<td><a href='./detalleTarea.jsp?nombre=${tarea.titulo}'>DETALLAR</a></td>
	</tr>
</c:forEach>

</table>

<% 

conexion.close();
    } catch (Exception e)
{
   e.printStackTrace();
} 

%>


</body>
</html>